<!DOCTYPE html>
<!-- ng-app -->
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../../js/plugins/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <div ng-controller="cont">
        <!-- 视图组件 -->
    </div>

    <script>
        /* 自己定义的服务 $custom */
        var app = angular.module('app',[])
            .factory('$custom',function () {
                return {
                    print:function (msg) {
                        console.log(msg);
                    }
                };
            });
        var injector = angular.injector(['app','ng']);
        var fun = function($custom){
            $custom.print("执行成功！");
        }
        /* 可以理解为自动自行fun方法 */
        injector.invoke(fun);

        app.controller('cont',['$scope','$custom',function ($scope,$custom) {
            // 控制代码
        }])

    </script>
</body>
</html>